﻿using System;
using System.Collections.Generic;
using System.Text;
using NLBS.Entity;

namespace NLBS.Syndication
{
   public class RssWriter:BaseRssWriter<Article>
    {

        /// <summary>
        /// Creates a new <see cref="RssWriter"/> instance.
        /// </summary>
        /// <param name="entries">Entries.</param>
        /// <param name="dateLastViewedFeedItemPublished"></param>
        /// <param name="useDeltaEncoding"></param>
       public RssWriter(IList<Article> entries, DateTime dateLastViewedFeedItemPublished, bool useDeltaEncoding)
            : base(dateLastViewedFeedItemPublished, useDeltaEncoding)
        {
            this.Items = entries;
            this.UseAggBugs = true;
        }

        protected override string GetCategoriesFromItem(Article item)
        {
            return item.CategoryName.ToString();
        }

        protected override string GetTitleFromItem(Article item)
        {
            return item.Title;
        }

        protected override bool IsComment
        {
            get { return false; }
        }

        protected override string GetLinkFromItem(Article item)
        {
            return blogInfo.BaseUrl+"article.aspx?id=" + item.ArticleID.ToString();
        }

        protected override string GetBodyFromItem(Article item)
        {
            return item.Content0;
        }

        protected override string GetAuthorFromItem(Article item)
        {
            return item.Author;
        }

        protected override DateTime GetPublishedDateUtc(Article item)
        {
            return item.PostTime;
        }

        protected override bool ItemCouldContainComments(Article item)
        {
            throw new NotImplementedException();
        }

        protected override bool ItemAllowsComments(Article item)
        {
            throw new NotImplementedException();
        }

        protected override bool CommentsClosedOnItem(Article item)
        {
            return false;
        }

        protected override int GetFeedbackCount(Article item)
        {
            throw new NotImplementedException();
        }

        protected override DateTime GetSyndicationDate(Article item)
        {
            return DateTime.Now;
        }

        protected override string GetCommentRssLink(Article item)
        {
            return blogInfo.BaseUrl + "feed.aspx?q=comment&id=" + item.ArticleID.ToString();
        }
    }
}
